namespace QMVnSoft.Lists
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmMDSDEditor : FormListEditor
    {
        private IContainer components;
        private LabelControl lblMa_MDSD;
        private LabelControl lblTen_MDSD;
        private LabelControl lblTen_MDSD_E;
        private TextControl txtMa_MDSD;
        private TextControl txtTen_MDSD;
        private TextControl txtTen_MDSD_E;

        public FormDmMDSDEditor()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            //ComponentResourceManager manager = new ComponentResourceManager(typeof(FormDmMDSDEditor));
            this.txtMa_MDSD = new TextControl();
            this.lblMa_MDSD = new LabelControl();
            this.txtTen_MDSD = new TextControl();
            this.lblTen_MDSD = new LabelControl();
            this.txtTen_MDSD_E = new TextControl();
            this.lblTen_MDSD_E = new LabelControl();
            base.SuspendLayout();
            base.txtMa_Loai3.FirstFilter = "Type = 'MD3'";
            base.txtMa_Loai3.Location = new Point(0x18c, 0x5e);
            base.txtMa_Loai3.Size = new Size(0x85, 20);
            base.txtMa_Loai3.TabIndex = 5;
            base.txtMa_Loai2.FirstFilter = "Type = 'MD2'";
            base.txtMa_Loai2.Location = new Point(0x103, 0x5e);
            base.txtMa_Loai2.Size = new Size(0x86, 20);
            base.txtMa_Loai2.TabIndex = 4;
            base.txtMa_Loai1.FirstFilter = "Type = 'MD1'";
            base.txtMa_Loai1.Location = new Point(0x7b, 0x5e);
            base.txtMa_Loai1.Size = new Size(0x85, 20);
            base.txtMa_Loai1.TabIndex = 3;
            base.lblPhan_Loai.Location = new Point(12, 0x61);
            this.txtMa_MDSD.CharacterCasing = CharacterCasing.Upper;
            this.txtMa_MDSD.CheckTextSearched = false;
            this.txtMa_MDSD.DisabledForeColor = Color.Empty;
            this.txtMa_MDSD.Font = new Font("Arial", 8.25f);
            this.txtMa_MDSD.Location = new Point(0x7b, 0x1c);
            this.txtMa_MDSD.MaxLength = 0x20;
            this.txtMa_MDSD.Name = "txtMa_MDSD";
            this.txtMa_MDSD.OldValue = null;
            this.txtMa_MDSD.Size = new Size(0x85, 20);
            this.txtMa_MDSD.TabIndex = 0;
            this.txtMa_MDSD.UserTextLength = AppInstance.TextControlLength.ItemCode;
            this.txtMa_MDSD.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtMa_MDSD.Value = null;//manager.GetObject("txtMa_MDSD.Value");
            this.lblMa_MDSD.AutoSize = true;
            this.lblMa_MDSD.Font = new Font("Arial", 8.25f);
            this.lblMa_MDSD.Location = new Point(12, 0x1f);
            this.lblMa_MDSD.Name = "lblMa_MDSD";
            this.lblMa_MDSD.Size = new Size(0x43, 14);
            this.lblMa_MDSD.TabIndex = 4;
            this.lblMa_MDSD.Text = "Mã mục đích";
            this.txtTen_MDSD.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_MDSD.CheckTextSearched = false;
            this.txtTen_MDSD.DisabledForeColor = Color.Empty;
            this.txtTen_MDSD.Font = new Font("Arial", 8.25f);
            this.txtTen_MDSD.Location = new Point(0x7b, 50);
            this.txtTen_MDSD.MaxLength = 128;
            this.txtTen_MDSD.Name = "txtTen_MDSD";
            this.txtTen_MDSD.OldValue = null;
            this.txtTen_MDSD.Size = new Size(0x196, 20);
            this.txtTen_MDSD.TabIndex = 1;
            this.txtTen_MDSD.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTen_MDSD.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTen_MDSD.Value = null;//manager.GetObject("txtTen_MDSD.Value");
            this.lblTen_MDSD.AutoSize = true;
            this.lblTen_MDSD.Font = new Font("Arial", 8.25f);
            this.lblTen_MDSD.Location = new Point(12, 0x35);
            this.lblTen_MDSD.Name = "lblTen_MDSD";
            this.lblTen_MDSD.Size = new Size(0x47, 14);
            this.lblTen_MDSD.TabIndex = 4;
            this.lblTen_MDSD.Text = "Tên mục đích";
            this.txtTen_MDSD_E.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_MDSD_E.CheckTextSearched = false;
            this.txtTen_MDSD_E.DisabledForeColor = Color.Empty;
            this.txtTen_MDSD_E.Font = new Font("Arial", 8.25f);
            this.txtTen_MDSD_E.Location = new Point(0x7b, 0x48);
            this.txtTen_MDSD_E.MaxLength = 128;
            this.txtTen_MDSD_E.Name = "txtTen_MDSD_E";
            this.txtTen_MDSD_E.OldValue = null;
            this.txtTen_MDSD_E.Size = new Size(0x196, 20);
            this.txtTen_MDSD_E.TabIndex = 2;
            this.txtTen_MDSD_E.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTen_MDSD_E.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTen_MDSD_E.Value = null;//manager.GetObject("txtTen_MDSD_E.Value");
            this.lblTen_MDSD_E.AutoSize = true;
            this.lblTen_MDSD_E.Font = new Font("Arial", 8.25f);
            this.lblTen_MDSD_E.Location = new Point(12, 0x4b);
            this.lblTen_MDSD_E.Name = "lblTen_MDSD_E";
            this.lblTen_MDSD_E.Size = new Size(0x4a, 14);
            this.lblTen_MDSD_E.TabIndex = 4;
            this.lblTen_MDSD_E.Text = "Tên tiếng Anh";
            base.AddTitleText = "Thêm mới mục đích sử dụng";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x222, 128);
            base.Controls.Add(this.lblTen_MDSD_E);
            base.Controls.Add(this.lblTen_MDSD);
            base.Controls.Add(this.lblMa_MDSD);
            base.Controls.Add(this.txtTen_MDSD_E);
            base.Controls.Add(this.txtTen_MDSD);
            base.Controls.Add(this.txtMa_MDSD);
            base.EditTitleText = "Sửa mục đích sử dụng";
            base.FirstFreeCode = "MD1";
            base.Name = "FormDmMDSDEditor";
            base.SecondFreeCode = "MD2";
            this.Text = "Thêm mới mục đích sử dụng";
            base.ThirdFreeCode = "MD3";
            base.Controls.SetChildIndex(base.lblPhan_Loai, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai1, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai2, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai3, 0);
            base.Controls.SetChildIndex(this.txtMa_MDSD, 0);
            base.Controls.SetChildIndex(this.txtTen_MDSD, 0);
            base.Controls.SetChildIndex(this.txtTen_MDSD_E, 0);
            base.Controls.SetChildIndex(this.lblMa_MDSD, 0);
            base.Controls.SetChildIndex(this.lblTen_MDSD, 0);
            base.Controls.SetChildIndex(this.lblTen_MDSD_E, 0);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (string.IsNullOrEmpty(this.txtMa_MDSD.Text))
            {
                MessageBox.Show("Chưa nhập mã mục đích!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (string.IsNullOrEmpty(this.txtTen_MDSD.Text))
            {
                MessageBox.Show("Chưa nhập tên mục đích!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_MDSD"] = this.txtMa_MDSD.Value;
            localCurrentRow["Ten_MDSD"] = this.txtTen_MDSD.Value;
            localCurrentRow["Ten_MDSD_E"] = this.txtTen_MDSD_E.Value;
            localCurrentRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            DmMDSDDataAccess access = new DmMDSDDataAccess();
            if (base.ShowMessage(localCurrentRow, access.SaveRow(base.NewChecked, localCurrentRow)))
            {
                return false;
            }
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_MDSD.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_MDSD.Value = base.LocalCurrentRow["Ma_MDSD"];
            this.txtTen_MDSD.Value = base.LocalCurrentRow["Ten_MDSD"];
            this.txtTen_MDSD_E.Value = base.LocalCurrentRow["Ten_MDSD_E"];
            base.txtMa_Loai1.Value = base.LocalCurrentRow["Ma_Loai1"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.OnShow();
        }
    }
}

